<?php
defined('IN_IXDCW') or exit('Access Denied');
$tab = isset($tab) ? intval($tab) : 0;
$all = isset($all) ? intval($all) : 0;
if($submit) {

	foreach($setting['service'] as $k => $v) {
		if (!$v) {
			unset($setting['service'][$k]);
		}
	}
	$setting['service'] = implode(',', array_keys($setting['service']));
	update_setting($moduleid, $setting);
	PCache::sysModule($moduleid);
	dmsg('更新成功', '?moduleid='.$moduleid.'&file='.$file.'&tab='.$tab);
} else {
	$serviceTypes = get_maincat(20, 2);
	extract(Str::htmlSpecialChars($MOD));
	$service = explode(',', $service);
	if($kw) {
		$all = 1;
		ob_start();
	}
	include tpl('setting', $module);
	if($kw) {
		$data = $content = ob_get_contents();
		ob_clean();
		$data = preg_replace('\'(?!((<.*?)|(<a.*?)|(<strong.*?)))('.$kw.')(?!(([^<>]*?)>)|([^>]*?</a>)|([^>]*?</strong>))\'si', '<span class=highlight>'.$kw.'</span>', $data);
		$data = preg_replace('/<span class=highlight>/', '<a name=high></a><span class=highlight>', $data, 1);
		echo $data ? $data : $content;
	}
}